<?php
/**
 * 微信公众号相关操作
 */
namespace Api;
use Kuyuan\WqCore\api\Api;
use Kuyuan\WqCore\util\Util;

class WeChat extends Api
{
    private $WeChat = null;

    public function __construct()
    {
        parent::__construct();
        $this->WeChat = new \Controller\WeChat();
    }

    /**
     *查询用户是否关注了公众号
     */
    public function testAttention()
    {
        Util::returns(array("code"=>0,"data"=>$this->WeChat->testAttention()));
    }

    /**
     * 获取关注二维码
     */
    public function getAttentionQrcode()
    {
        Util::returns(array("code"=>0,"data"=>$this->WeChat->getAttentionQrcode()));
    }

    /**
     * 发红包是否显示关注二维码
     */
    public function sendAttention()
    {
        Util::appointGet();
        $Setting = $this->newController("Setting");
        $_setting = $Setting->find();
        if($_setting["open_attention"] && $_setting["hint_attention"] && !$this->WeChat->testAttention()) {
            $_result = array("code"=>0,"data"=>1);
        } else {
            $_result = array("code"=>0,"data"=>0);
        }
        Util::returns($_result);
    }
}